package com.hmdp.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedissonConfig {

    // 从 application.yml 中读取 Redis 配置
    @Value("${spring.redis.host}")
    private String redisHost; // 读取 host: 192.168.93.130

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer().setAddress(String.format("redis://%s:6379",this.redisHost))
                .setPassword("123456");
        return Redisson.create(config);
    }

}
